//首次定位
$$.ajax({
	    url:"http://192.168.5.22:8080/webmeeting/user/location",
	    method:"GET",
		data:{},
		dataType:'json',
		timeout:4000,
		success: function (ajaxresult) {
			ajaxresult = ajaxresult.split(':');
			var cX = parseFloat(ajaxresult[0]);
			var cY = parseFloat(ajaxresult[1]);
			var cbx = Math.abs(Math.round(cX/mapRatioW/netrectW)-1);
			var cby = Math.abs(Math.round(cY/mapRatioH/netrectH)-1);
			if(blocks1[cby][cbx] == 0){
				currentBlockX = cbx;
				currentBlockY = cby;
				$$('.current-icon').data('blockX',currentBlockX);
				$$('.current-icon').data('blockY',currentBlockY);
				setCurrentPos();
			}
		},
		error:function(){
			myApp.alert('请求失败');
		}
});
//每隔五秒刷新定位
var getLoctimer =  setInterval(function(){
		$$.ajax({
		    url:"http://192.168.5.22:8080/webmeeting/user/location",
		    method:"GET",
			data:{},
			dataType:'json',
			timeout:4000,
			success: function (ajaxresult) {
				ajaxresult = ajaxresult.split(':');
				var cX = parseFloat(ajaxresult[0]);
				var cY = parseFloat(ajaxresult[1]);
				var cbx = Math.abs(Math.round(cX/mapRatioW/netrectW)-1);
				var cby = Math.abs(Math.round(cY/mapRatioH/netrectH)-1);
				if(blocks1[cby][cbx] == 0){
					currentBlockX = cbx;
					currentBlockY = cby;
					$$('.current-icon').data('blockX',currentBlockX);
					$$('.current-icon').data('blockY',currentBlockY);
					setCurrentPos();
				}
			},
			error:function(){
				myApp.alert('请求失败');
			}
		});
},getLoctime);

/*测试*/
//var cX=0;
//var cY=0; 
//var testtimer = setInterval(function(){
//	cX+=1;
//	cY+=1;
//	if(cX>40){
//		clearInterval(testtimer);
//	}
//	var cbx = Math.abs(Math.round(cX/mapRatioW/netrectW)-1);
//	var cby = Math.abs(Math.round(cY/mapRatioH/netrectH)-1);
//	if(blocks1[cby][cbx] == 0){
//		currentBlockX = cbx;
//		currentBlockY = cby;
//		$$('.current-icon').data('blockX',currentBlockX);
//		$$('.current-icon').data('blockY',currentBlockY);
//		setCurrentPos();
//	}	
//},1000);


